<template>
  <div>
    <!-- 头部搜索 -->
    <div class="header">
      <div class="header">
        <van-nav-bar
          left-arrow
          @click-left="backHome"
          @click-right="searching"
          right-text="搜索"
        >
          <template #title>
            <van-search
              shape="round"
              placeholder="请输入搜索关键词"
             
              @click="fn"
            />
          </template>
        </van-nav-bar>
      </div>
    </div>
    <div class="main">
      <!-- 左列表 -->
      <div class="left">
        <van-sidebar v-model="activeKey">
          <van-sidebar-item
            :title="item"
            v-for="(item, index) in kindList"
            :key="index"
          />
        </van-sidebar>
      </div>
      <!-- 右列表 -->
      <div class="right">
        <van-tabs v-model="active">
          <van-tab title="标签 1">内容 1</van-tab>
          <van-tab title="标签 2">内容 2</van-tab>
          <van-tab title="标签 3">内容 3</van-tab>
          <van-tab title="标签 4">内容 4</van-tab>
        </van-tabs>
      </div>
    </div>
  </div>
</template>

<script>
import { getKindList, getKindListAll } from "../api/kind";
import Vue from "vue";
import { Sidebar, SidebarItem, Tab, Tabs } from "vant";

Vue.use(Sidebar);
Vue.use(SidebarItem);
Vue.use(Tab);
Vue.use(Tabs);
export default {
  name: "Kind",
  components: {},
  data() {
    return {
      activeKey: 0,
      kindList: [],
      active: "2",
    };
  },
  created() {
    getKindList().then((res) => {
      console.log(res.data);
      this.kindList = res.data.data;
    });
  },
  methods: {
    fn(){
      this.$router.push("/Search")
    },
    backHome() {
      this.$router.push("/home");
    },
    //搜索页
    searching() {
         this.$router.push("/Search")
    },
    // 左列分类
    getKind(index) {
      console.log(this.kindList[index]);
      getKindListAll({ category: this.kindList[index] }).then((res) => {
        console.log(res.data);
      });
    },
  },
};
</script>

<style scoped>
.main {
  background-color: #f2f2f2;
  display: flex;
}
.main .left {
  width: 0.8rem;
}
.main .right {
  flex: 1;
}
</style>